package com.kstech.test.padxmledit;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.kstech.test.padxmledit.domain.QCItem;

/**
 * Created by lijie on 2016/12/22.
 */

public class QCparamView extends LinearLayout {
    private  TextView tvParam;
    private  EditText etMax;
    private  EditText etMix;
    public QCparamView(Context context,QCItem.QCParam param) {
        super(context);
        initView(param,context);
    }

    public QCparamView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public QCparamView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    private void initView(QCItem.QCParam param,Context context){
        View view = View.inflate(context,R.layout.ll_param_item,null);
        tvParam = (TextView) view.findViewById(R.id.tv_param);
        etMax = (EditText) view.findViewById(R.id.qc_max);
        etMix = (EditText) view.findViewById(R.id.qc_mix);
        tvParam.setText(param.Param);
        etMax.setText(param.ValidMax);
        etMix.setText(param.ValidMin);
        this.addView(view);
    }
    public QCItem.QCParam getParam(){
        QCItem.QCParam param = new QCItem.QCParam();
        param.Param = tvParam.getText().toString().trim();
        param.ValidMax = etMax.getText().toString().trim();
        param.ValidMin = etMix.getText().toString().trim();
        param.ValidAvg = "";
        return param;
    }
}
